<?php
// $Id: index.php,v 2.10.1 2005/03/25 11:16:00 Yoshi.Sakai Exp $
include '../../../include/cp_header.php';
if(
	(!defined('XOOPS_ROOT_PATH')) || 
	(!is_object($xoopsUser)) || 
	(!$xoopsUser->isAdmin()) ){
	exit();
}
include_once '../conf.php';
require_once XOOPS_ROOT_PATH.'/modules/popnupblog/popnupblog.php';
xoops_cp_header();
checkPermit();

include_once './adminmenu.php';

$groupnames = $member_handler->getGroupList(); 
$categories = PopnupBlogUtils::get_categories();
$alias_uid = $sends_uid = 0;
$alias_uname = isset($HTTP_POST_VARS['alias_uname']) ? $HTTP_POST_VARS['alias_uname'] : '';
$sends_uname = isset($HTTP_POST_VARS['sends_uname']) ? $HTTP_POST_VARS['sends_uname'] : '';
$alias_email = isset($HTTP_POST_VARS['alias_email']) ? $HTTP_POST_VARS['alias_email'] : '';
$sends_email = isset($HTTP_POST_VARS['sends_email']) ? $HTTP_POST_VARS['sends_email'] : '';
if ($alias_uname){ $alias_uid = isset($HTTP_POST_VARS['alias_uid']) ? intval($HTTP_POST_VARS['alias_uid']) : 0; }
if ($sends_uname){ $sends_uid = isset($HTTP_POST_VARS['sends_uid']) ? intval($HTTP_POST_VARS['sends_uid']) : 0; }

// updater check
/*
$updates = PopnupBlog::check_updater();
if($updates != false){
	if( !isset($updates['response']) || 
	    (empty($updates['response']))  ||
		($updates['response'] == $updates['local'])
	){
	}else{
//		echo " local_version='".$updates['local']."' new_version='".$updates['response']."'";
		echo "<center><h2><a href='http://sourceforge.jp/projects/xoops-modules/' target='_blank'>"._AM_POPNUPBLOG_ADMIN_NEW_VERSION.'('.$updates['response'].")</a></h2></center><br />\n";
	}
}
echo '<b><a href='.XOOPS_URL.'/modules/system/admin.php?fct=preferences&amp;op=showmod&amp;mod='
	.$xoopsModule->getVar('mid').">"._AM_PREFERENCES."</a></b><P>";
*/
?>
	&nbsp;<br />
<?php
if ( isset($HTTP_POST_VARS['delete_ok']) ) {
	$targetUid = isset($HTTP_POST_VARS['uid']) ? intval($HTTP_POST_VARS['uid']) : 0;
	$targetBid = isset($HTTP_POST_VARS['bid']) ? intval($HTTP_POST_VARS['bid']) : 0;
	if($targetUid > 0){
		$blog = new PopnupBlog($targetBid);
		$blog->deleteAll();
	}
}
if ( isset($HTTP_POST_VARS['delete']) ) {
	$targetUid = isset($HTTP_POST_VARS['uid']) ? intval($HTTP_POST_VARS['uid']) : 0;
	$targetBid = isset($HTTP_POST_VARS['bid']) ? intval($HTTP_POST_VARS['bid']) : 0;
	echo "<table width='100%' border='0' cellspacing='1' class='outer'><form action='index.php' method='post'>";
	echo "<tr><td align='center'><h4>Delete blogid: ". $targetBid."</h4>";
	echo "<input type=hidden name=uid value=".$targetUid." />";
	echo "<input type=hidden name=bid value=".$targetBid." />";
	echo "<input type=submit name=Cancel value=Cancel />&nbsp<input type=submit name=delete_ok value=OK />";
	echo "</form></td></tr></table>";
	xoops_cp_footer();
	exit();
} 
if(	isset($HTTP_POST_VARS['edit']) || 
	isset($HTTP_POST_VARS['create']) || 
	isset($HTTP_POST_VARS['delete']) || 
	isset($HTTP_POST_VARS['add_alias']) || 
	isset($HTTP_POST_VARS['add_sends']) || 
	isset($HTTP_POST_VARS['reject']) ){
	if(!xoops_refcheck()){
		redirect_header(XOOPS_URL.'/modules/popnupblog/',2,'Referer Check Failed');
		exit();
	}
}
if(isset($HTTP_POST_VARS['edit'])) {
	$targetUid = isset($HTTP_POST_VARS['uid']) ? intval($HTTP_POST_VARS['uid']) : 0;
	$targetBid = isset($HTTP_POST_VARS['bid']) ? intval($HTTP_POST_VARS['bid']) : 0;
	$targetGid = isset($HTTP_POST_VARS['gid']) ? intval($HTTP_POST_VARS['gid']) : 0;
	$cat_id = isset($HTTP_POST_VARS['cat_id']) ? intval($HTTP_POST_VARS['cat_id']) : 0;
	$canread    = isset($HTTP_POST_VARS['canread'])    ? intval($HTTP_POST_VARS['canread'])    : 0;
	$cancomment = isset($HTTP_POST_VARS['cancomment']) ? intval($HTTP_POST_VARS['cancomment']) : 0;
	$canvote    = isset($HTTP_POST_VARS['canvote'])    ? intval($HTTP_POST_VARS['canvote'])    : 0;
	$permission = $canread + $cancomment + $canvote;
	$title = isset($HTTP_POST_VARS['title']) ? ($HTTP_POST_VARS['title']) : "";
	$desc = isset($HTTP_POST_VARS['desc']) ? ($HTTP_POST_VARS['desc']) : "";
	$email = isset($HTTP_POST_VARS['email']) ? ($HTTP_POST_VARS['email']) : "";
	//      Modified by hoshiyan@hoshiba-farm.com 2004.8.4
	$emailalias = isset($HTTP_POST_VARS['emailalias']) ? ($HTTP_POST_VARS['emailalias']) : "";
	$emailsends = isset($HTTP_POST_VARS['emailsends']) ? ($HTTP_POST_VARS['emailsends']) : "";
	if($targetUid > 0){
		if($permission >= 0){
			$blog = new PopnupBlog($targetBid);
			$blog->setBlogInfo($targetGid, $cat_id, $permission, $title, $desc, $email);
			//PopnupBlogUtils::setEmailAliasInfo($targetBid,$emailalias);
		}
	}
}elseif(isset($HTTP_POST_VARS['create'])) {
	$targetUid = isset($HTTP_POST_VARS['uid']) ? intval($HTTP_POST_VARS['uid']) : 0;
	$gid = isset($HTTP_POST_VARS['gid']) ? intval($HTTP_POST_VARS['gid']) : 0;
	$cat_id = isset($HTTP_POST_VARS['cat_id']) ? intval($HTTP_POST_VARS['cat_id']) : 0;
	$canread    = isset($HTTP_POST_VARS['canread'])    ? intval($HTTP_POST_VARS['canread'])    : 0;
	$cancomment = isset($HTTP_POST_VARS['cancomment']) ? intval($HTTP_POST_VARS['cancomment']) : 0;
	$canvote    = isset($HTTP_POST_VARS['canvote'])    ? intval($HTTP_POST_VARS['canvote'])    : 0;
	$permission = $canread + $cancomment + $canvote;
	$title = isset($HTTP_POST_VARS['title']) ? ($HTTP_POST_VARS['title']) : "";
	$desc = isset($HTTP_POST_VARS['desc']) ? ($HTTP_POST_VARS['desc']) : "";
	$email = isset($HTTP_POST_VARS['email']) ? ($HTTP_POST_VARS['email']) : "";
	$emailalias = isset($HTTP_POST_VARS['emailalias']) ? ($HTTP_POST_VARS['emailalias']) : "";
	if($targetUid > 0){
		if($permission >= 0){
			if(PopnupBlogUtils::createNewBlogUser($targetUid,$gid,$cat_id,$permission, $title, $desc, $email, $emailalias)){
				echo '<font color="red">success: create blog uid='.$targetUid.'</font>';
			}else{
				echo '<font color="red">failed: create blog uid='.$targetUid.'</font>';
			}
		}
		
	}
}elseif(isset($HTTP_POST_VARS['delete'])) {
	$targetUid = isset($HTTP_POST_VARS['uid']) ? intval($HTTP_POST_VARS['uid']) : 0;
	$targetBid = isset($HTTP_POST_VARS['bid']) ? intval($HTTP_POST_VARS['bid']) : 0;
    if ( !empty( $ok ) ){
		if($targetUid > 0){
			$blog = new PopnupBlog($targetBid);
			$blog->deleteAll();
		}
    } 
}elseif(isset($HTTP_POST_VARS['reject'])) {
	$targetUid = isset($HTTP_POST_VARS['uid']) ? intval($HTTP_POST_VARS['uid']) : 0;
	if($targetUid > 0){
//		$blog = new PopnupBlog($targetBid);
		PopnupBlogUtils::deleteApplication($targetUid);
	}
}elseif ( isset($HTTP_POST_VARS['del_sends'])){
	// Add user(s) to the list for this forum.
	if ($HTTP_POST_VARS['emailsends']){
		$result = PopnupBlogUtils::mailalias_delete($HTTP_POST_VARS["bid"],2,$HTTP_POST_VARS["emailsends"]);
	}
}elseif (isset($HTTP_POST_VARS['del_alias'])){
	// Add user(s) to the list for this forum.
	if ($HTTP_POST_VARS['emailalias']){
		$result = PopnupBlogUtils::mailalias_delete($HTTP_POST_VARS["bid"],1,$HTTP_POST_VARS["emailalias"]);
	}
}elseif (isset($HTTP_POST_VARS['cnf_alias'])){
	$myrow = PopnupBlogUtils::find_uid_mail($HTTP_POST_VARS["alias_uname"]);
	$alias_uid = $myrow[0];
	$alias_email = $myrow[1];
}elseif (isset($HTTP_POST_VARS['add_alias'])){
	// Add user(s) to the list for this forum.
	$result = PopnupBlogUtils::mailalias_add($HTTP_POST_VARS["bid"],1,$alias_email,$alias_uid);
	if (!$result){ echo '<h1>'._AM_POPNUPBLOG_CANTADDEMAIL.'</h1>'; }
	$alias_uname = $alias_email = null;
}elseif (isset($HTTP_POST_VARS['cnf_sends'])){
	// Add user(s) to the list for this forum.
	$myrow = PopnupBlogUtils::find_uid_mail($HTTP_POST_VARS["sends_uname"]);
	$sends_uid = $myrow[0];
	$sends_email = $myrow[1];
}elseif (isset($HTTP_POST_VARS['add_sends'])){
	$result = PopnupBlogUtils::mailalias_add($HTTP_POST_VARS["bid"],2,$sends_email,$sends_uid);
	if (!$result){ echo '<h1>'._AM_POPNUPBLOG_CANTADDEMAIL.'</h1>'; }
	$sends_uname = $sends_email = null;
}
$appList = popnupblog::getAllApplication();
if(count($appList) > 0){
?>
<table width='100%' border='0' cellspacing='1' class='outer'>
<tr><td colspan="5" class="head" ><b><?php echo _AM_POPNUPBLOG_APPLICATED_USER; ?></b></td></tr>
		<tr class="head">
			<th width="5%">Edit</th>
			<th>Title<br>Category<br>Create date</th>
			<th colspan=2>Permission</th>
			<th width="20%">(uid)User<br>Group<br>Email</th>
		</tr>
<?php foreach($appList as $app){ 
		$canread     = $app['permission'] & 0x07;
		$cancomment = ($app['permission'] & 0x38)>>3;
		$canvote    = ($app['permission'] & 0x1c0)>>6;
		$opt[0] = $opt[1] = $opt[2] = $opt[3] = $opt[4] = $opt[5] = $opt[6] = $opt[7] = '';
		$opt[$canread] = ' CHECKED';
		$cmt[0] = $cmt[1] = $cmt[2] = $cmt[3] = $cmt[4] = $cmt[5] = $cmt[6] = $cmt[7] = '';
		$cmt[$cancomment] = ' CHECKED';
		$vte[0] = $vte[1] = $vte[2] = $vte[3] = $vte[4] = $vte[5] = $vte[6] = $vte[7] ='';
		$vte[$canvote] = ' CHECKED';
?>
		<tr><form method="post" action="index.php">
		<tr class="even">
		<td rowspan=4>
			<input type="submit" name="create" value="<?php echo _AM_POPNUPBLOG_ALLOW_APPLICATION; ?>"><p>
			<input type="submit" name="reject" value="<?php echo _AM_POPNUPBLOG_REJECT_APPLICATION; ?>" />
			<input type=hidden name=uid value='<?php echo $app['uid'] ?>' />
			<input type=hidden name=application value='application' />
		</td>
		<td>
			<input type="text" name="title" value="<?php echo $app['title']; ?>" />
		</td>
		<td><?php echo _AM_POPNUPBLOG_ADMIN_PERMISSION0; ?></td><td>
			<input type=radio name=canread value= 7 <?php echo $opt[7]; ?>><?php echo _AM_PRIVATE;?></input>
			<input type=radio name=canread value= 6 <?php echo $opt[6]; ?>><?php echo _AM_MODERATOR;?></input>
			<input type=radio name=canread value= 1 <?php echo $opt[1]; ?>><?php echo _MEMBERS;?></input>
			<input type=radio name=canread value= 0 <?php echo $opt[0]; ?>><?php echo _GUESTS;?></input>
		</td>
		<td rowspan=4>
			<?php echo "(".$app['uid'].") ".XoopsUser::getUnameFromId($app['uid']); ?>
			<br><?php echo _AM_POPNUPBLOG_ADMIN_GROUP.PopnupBlogUtils::mkselect('gid',$groupnames, $app['gid']); ?>
			<input type="text" name="email" value="<?php echo  $app['email'];?>" />
			<input type="text" name="emailalias" value="<?php echo  $app['emailalias'];?>" />
		</td>
		<? //echo popnupblog::getEmailByUid($app['uid']); ?>
		</tr>
		<tr class="even">
		<td><span class='fg2'><?php echo _AM_CATEGORY;?></span>
			<?php
			if ( $categories ) {
				echo PopnupBlogUtils::mkselect('cat_id',$categories,$app['cat_id']);
			} else {
				echo "<select name='cat_id'><option value=\"0\">"._AM_NONE."</option>\n";
			}
			?>
    	   	</select>
		</td>
		<td><?php echo _AM_POPNUPBLOG_ADMIN_PERMISSION1; ?></td><td>
			<input type=radio name=cancomment value=56 <?php echo $cmt[7]; ?>><?php echo _AM_PRIVATE;?></input>
			<input type=radio name=cancomment value=48 <?php echo $cmt[6]; ?>><?php echo _AM_MODERATOR;?></input>
			<input type=radio name=cancomment value= 8 <?php echo $cmt[1]; ?>><?php echo _MEMBERS;?></input>
			<input type=radio name=cancomment value= 0 <?php echo $cmt[0]; ?>><?php echo _GUESTS;?></input>
		</td></tr>
		<tr class="even"><td>
			<?php echo date("Y-m-d", $app['create_date']); ?>
		</td>
		<td><?php echo _AM_POPNUPBLOG_ADMIN_PERMISSION2; ?></td><td>
			<input type=radio name=canvote value=448 <?php echo $vte[7]; ?>><?php echo _AM_PRIVATE;?></input>
			<input type=radio name=canvote value=384 <?php echo $vte[6]; ?>><?php echo _AM_MODERATOR;?></input>
			<input type=radio name=canvote value= 64 <?php echo $vte[1]; ?>><?php echo _MEMBERS;?></input>
			<input type=radio name=canvote value=  0 <?php echo $vte[0]; ?>><?php echo _GUESTS;?></input>
		</td>
		</tr>
        <tr class="even"><td align="right">
			<span class='fg2'><?php echo _AM_BLOGDESCRIPTION;?></span>
		</td><td colspan=2>
			<TEXTAREA name='desc' ROWS="3" COLS="50" WRAP="VIRTUAL"><?php echo $app['desc']?></TEXTAREA></td>
		</td></tr>
		</form>
		</tr>
	<?php	} ?>
	</table><br /><?php } ?>

	<table width='100%' border='0' cellspacing='1' class='outer'>
	<tr><td class="head" colspan="8"><b><?php echo _AM_POPNUPBLOG_ADMIN_EDIT; ?></b></td></tr>
	<tr><td valign="top" class='even' align='center' width='20%'>
		<form action="<?php echo $HTTP_SERVER_VARS['PHP_SELF'];?>" method="post">
		<select name="uid" size="10" style="width: 100px;">
		<?php
		$sql = "SELECT u.uid,u.uname FROM ".$xoopsDB->prefix("users")." u, ".$xoopsDB->prefix("popnupblog_info")." f WHERE u.uid = f.uid Group by u.uid ORDER BY uname ASC";
		if (!$result = $xoopsDB->query($sql)){
			echo"</td></tr></table>";
			xoops_cp_footer();
			exit();
		}
		while ($row = $xoopsDB->fetchArray($result)){
			?>
			<option value="<?php echo $row['uid'] ?>"> <?php echo $row['uname'] ?> </option>
			<?php
		}
		?>
		</select>
	</td><td colspan=3 class='odd' align='center'>
		<input type="submit" name="submit" value="<?php echo _AM_POPNUPBLOG_ADMIN_EDIT;?>" />
		</form>
	</td></tr>
	<tr class='bg1' align="left">
		<th><?php echo "("._AM_POPNUPBLOG_ADMIN_UID.")"._AM_POPNUPBLOG_ADMIN_NAME; ?></th>
		<th colspan=2><?php echo _AM_POPNUPBLOG_ADMIN_LASTUPDATE; ?></th>
	</tr>
<?php
	$targetUid = isset($HTTP_POST_VARS['uid']) ? intval($HTTP_POST_VARS['uid']) : 0;
	if ($targetUid==0){
		echo"</td></tr></table>";
		xoops_cp_footer();
		exit();
	}
	$users = array();
	$users = PopnupBlogUtils::getBlogInfo($targetUid);
	//print_r($users);
	if(count($users) > 0){
		$userHander = new XoopsUserHandler($xoopsDB);
		foreach ( $users as $user ) {
			$user['user'] = $userHander->get($user['uid']);
			$opt[0] = $opt[1] = $opt[2] = $opt[3] = $opt[4] = $opt[5] = $opt[6] = $opt[7] = '';
			$opt[$user['canread']] = ' CHECKED';
			$cmt[0] = $cmt[1] = $cmt[2] = $cmt[3] = $cmt[4] = $cmt[5] = $cmt[6] = $cmt[7] = '';
			$cmt[$user['cancomment']] = ' CHECKED';
			$vte[0] = $vte[1] = $vte[2] = $vte[3] = $vte[4] = $vte[5] = $vte[6] = $vte[7] ='';
			$vte[$user['canvote']] = ' CHECKED';
			?>
		<tr><form method="post" action="index.php">
			<tr><td class="head" align='left'>
				(<?php echo $user['uid']; ?>)<input type=hidden name=uid value='<?php echo $user['uid'] ?>' />
				<?php echo htmlspecialchars($user['user']->uname()); ?>
			</td><td class="head" colspan=2>
				<?php echo $user['lastUpdate']; ?>
			</td></tr>
			<tr><td class="even" align='right'>
				(BlogID)<?php echo _AM_POPNUPBLOG_ADMIN_BLOG_TITLE; ?>
			</td><td class="odd" colspan=2>
				(<?php echo $user['bid']; ?><input type=hidden name=bid value='<?php echo $user['bid'] ?>' />)
				<input type="text" name="title" value="<?php echo htmlspecialchars($user['title']); ?>" />
				&nbsp;&nbsp;<span class='fg2'><?php echo _AM_CATEGORY;?></span>
				<?php
				if ( $categories ) {
					echo PopnupBlogUtils::mkselect('cat_id',$categories,$user['cat_id']);
				} else {
					echo "<select name='cat_id'><option value=\"0\">"._AM_NONE."</option>\n";
				}
				?>
        		</select>
        		&nbsp;&nbsp;<?php echo _AM_POPNUPBLOG_ADMIN_GROUP.PopnupBlogUtils::mkselect('gid',$groupnames, $user['gid']); ?>
			</td></tr>
			<tr><td class="even" align="right"><?php echo _AM_BLOGDESCRIPTION; ?></td>
			<td class="odd" colspan=2>
				<TEXTAREA name='desc' ROWS="2" COLS="100%" WRAP="VIRTUAL"><?php echo $user['desc'];?></TEXTAREA>
			</td></tr>
			<tr><td class="even" align='right'><?php echo _AM_POPNUPBLOG_ADMIN_PERMISSION; ?>
			<?php echo _AM_POPNUPBLOG_ADMIN_PERMISSION0; ?></td><td class="odd" colspan=2>
				<input type=radio name=canread value= 7 <?php echo $opt[7]; ?>><?php echo _AM_PRIVATE;?></input>
				<input type=radio name=canread value= 6 <?php echo $opt[6]; ?>><?php echo _AM_MODERATOR;?></input>
				<input type=radio name=canread value= 1 <?php echo $opt[1]; ?>><?php echo _MEMBERS;?></input>
				<input type=radio name=canread value= 0 <?php echo $opt[0]; ?>><?php echo _GUESTS;?></input>
			</td></tr>
			<tr><td class="even" align='right'><?php echo _AM_POPNUPBLOG_ADMIN_PERMISSION1; ?></td><td class="odd" colspan=2>
				<input type=radio name=cancomment value=56 <?php echo $cmt[7]; ?>><?php echo _AM_PRIVATE;?></input>
				<input type=radio name=cancomment value=48 <?php echo $cmt[6]; ?>><?php echo _AM_MODERATOR;?></input>
				<input type=radio name=cancomment value= 8 <?php echo $cmt[1]; ?>><?php echo _MEMBERS;?></input>
				<input type=radio name=cancomment value= 0 <?php echo $cmt[0]; ?>><?php echo _GUESTS;?></input>
			</td></tr>
			<tr><td class="even" align='right'><?php echo _AM_POPNUPBLOG_ADMIN_PERMISSION2; ?></td><td class="odd" colspan=2>
				<input type=radio name=canvote value=448 <?php echo $vte[7]; ?>><?php echo _AM_PRIVATE;?></input>
				<input type=radio name=canvote value=384 <?php echo $vte[6]; ?>><?php echo _AM_MODERATOR;?></input>
				<input type=radio name=canvote value= 64 <?php echo $vte[1]; ?>><?php echo _MEMBERS;?></input>
				<input type=radio name=canvote value=  0 <?php echo $vte[0]; ?>><?php echo _GUESTS;?></input>
			</td></tr>
			<tr><td class="even" align='right'><?php echo _AM_POPNUPBLOG_ADMIN_BLOG_EMAIL."1"; ?></td>
			<td class="odd" colspan=2>
			<input type="text" name="email" value="<?php echo htmlspecialchars($user['email']); ?>" />
			<?php echo _AM_POPNUPBLOG_FORM_ADMIN_USAGE; ?>
			</td>
			</tr>
			<tr><td class="even" align='right'><?php echo _AM_POPNUPBLOG_ADMIN_BLOG_EMAIL."2"; ?></td>
			<td class="odd">
			<!--<form action="<?php echo $HTTP_SERVER_VARS['PHP_SELF'];?>" method="post">-->
			<select name="emailalias[]" size="5" multiple='multiple' style="width: 250px;">
			<?php echo $user['emailalias_options']; ?>
			</select>
			<input type="hidden" name="bid" value="<?php echo $user['bid'] ?>" />
			<input type="hidden" name="pid" value="1" />
			<input type="hidden" name="uid" value="<?php echo $targetUid ?>" />
			<input type="hidden" name="op" value="del_alias" />
			<input type="submit" name="del_alias" value="<?php echo _AM_REMOVE;?>" />
			<!--</form>-->
			</td><td class="odd">
			<?php echo _AM_POPNUPBLOG_ADMIN_UNAME; ?>
			<input type="text" SIZE="8" name="alias_uname" value="<?php echo $alias_uname;?>"/>&nbsp;
			<input type="submit" name="cnf_alias" value="<?php echo _AM_CONFIRM;?>" />
			<input type="hidden" name="bid" value="<?php echo $user['bid'] ?>" />
			<input type="hidden" name="pid" value="1" />
			<input type="hidden" name="uid" value="<?php echo $targetUid ?>" />
			<br />email&nbsp;<input type="text" name="alias_email" value="<?php echo $alias_email;?>" />
			<input type="hidden" name="alias_uid" value="<?php echo $alias_uid;?>" />
			<input type="submit" name="add_alias" value="<?php echo _AM_ADD;?>" />
			</td></tr>
			<tr><td class="even" align='right'><?php echo _AM_POPNUPBLOG_ADMIN_SEND_EMAIL; ?></td>
			<td class="odd">
			<select name="emailsends[]" size="5" multiple='multiple' style="width: 250px;">
			<?php echo $user['emailsends_options']; ?>
			</select>
			<input type="hidden" name="bid" value="<?php echo $user['bid'] ?>" />
			<input type="hidden" name="pid" value="2" />
			<input type="hidden" name="uid" value="<?php echo $targetUid ?>" />
			<input type="submit" name="del_sends" value="<?php echo _AM_REMOVE;?>" />
			</td><td class="odd">
			<?php echo _AM_POPNUPBLOG_ADMIN_UNAME; ?>
			<input type="text" SIZE="8" name="sends_uname" value="<?php echo $sends_uname;?>"/>&nbsp;
			<input type="submit" name="cnf_sends" value="<?php echo _AM_CONFIRM;?>" />
			<input type="hidden" name="bid" value="<?php echo $user['bid'] ?>" />
			<input type="hidden" name="pid" value="2" />
			<input type="hidden" name="uid" value="<?php echo $targetUid ?>" />
			<br />email&nbsp;<input type="text" name="sends_email" value="<?php echo $sends_email;?>" />
			<input type="hidden" name="sends_uid" value="<?php echo $sends_uid;?>" />
			<input type="submit" name="add_sends" value="<?php echo _AM_ADD;?>" />
			</td></tr>
			<td class="even" align="center" colspan=3>
				<?php echo _AM_POPNUPBLOG_ADMIN_OPERATION; ?>&nbsp;&nbsp;
				<input type=submit name='edit' value='edit' />&nbsp;&nbsp;
				<input type=submit name='delete' value='delete' />
			</td></tr>
			</form>
		</tr><?php
		}
	}	
?>
</table>


<br /><center>
<a href="http://sourceforge.jp/">
	<img src="http://sourceforge.jp/sflogo.php?group_id=757" width="96" height="31" border="0" alt="SourceForge.jp" target="_blank">
</a> 
<a href="http://feeds.archive.org/validator/check?url=<?php echo XOOPS_URL; ?>/modules/popnupblog/backend.php" target="_blank">
	<img src="<?php echo XOOPS_URL; ?>/modules/popnupblog/rss-valid.gif" border="0">
</a><br />
Created by <a href="http://www.bluemooninc.biz/" target="_blank">Bluemoon inc.</a>
</center>
<?php
xoops_cp_footer();

/*****************************************************************************
	Check Permition
*****************************************************************************/
function checkPermit(){
	global $xoopsModule;

	$modpath = XOOPS_ROOT_PATH."/modules/".$xoopsModule->dirname();
	$permit_err = array();
	$_check_list = array(
		XOOPS_ROOT_PATH.$GLOBALS['BlogCNF']['img_dir'],
		XOOPS_ROOT_PATH.$GLOBALS['BlogCNF']['thumb_dir'],
		$modpath."/log/"
		);

	if ($dir = @opendir($modpath."/log/")) {
		while($file = readdir($dir)) {
			if($file == ".." || $file == "." || eregi("^\.(.*)",$file)) continue;
			array_push($_check_list, $modpath."/log/".$file);
		}
		closedir($dir);
	}

	foreach($_check_list as $dir){
		if(!is_writable($dir)){
			$permit_err[] = _AM_POPNUPBLOG_PERMITIONERR."=> ".$dir;
		}
	}

	$_alert_icon = "<img src='../images/alert.gif'>&nbsp;</img>";
//	$_alert_icon = "<img src='../caution.gif' height='15' width='50'>&nbsp;";
	foreach($permit_err as $er_msg){
//		echo "<img src='$_alert_icon' height='15' width='50'>&nbsp;$er_msg<br />";
		echo "$_alert_icon$er_msg<br />";
	}
}

?>

